﻿@inherits LayoutComponentBase

<PageTitle>FlowLearningPlatform</PageTitle>

<Layout Style="min-height: 100vh; ">
    <Sider Breakpoint="@BreakpointType.Sm"
           CollapsedWidth="64" >
        <Affix OffsetTop="10">
            <AuthorizeView Roles="教师,学生,管理员">
                <Authorized>
                    <Menu Theme="MenuTheme.Dark"  Mode="MenuMode.Inline">
                    <MenuItem Key="0">
                        <Icon Type="home" Theme="outline" />
                        <NavLink href="/">返回首页</NavLink>
                    </MenuItem>                   
                    <MenuItem Key="2">
                        <Icon Type="solution" Theme="outline" />
                        <NavLink Match="NavLinkMatch.Prefix" href="/course">课程管理</NavLink>
                    </MenuItem>
                    @if(context.User.IsInRole("教师")||context.User.IsInRole("管理员"))
                    {
                        <MenuItem Key="1">
                            <Icon Type="notification" Theme="outline" />
                            <NavLink Match="NavLinkMatch.Prefix" href="/announcement">公告管理</NavLink>
                        </MenuItem>
                        if(context.User.IsInRole("管理员"))
                        {
                            RenderFragment sub1Title =
                                @<span>
                                    <Icon Type="user" Theme="outline" />
                                    用户管理
                                </span>
                            ;
                            <SubMenu Key="sub1" TitleTemplate=sub1Title>
                                <MenuItem Key="3">教师</MenuItem>
                                <MenuItem Key="4">学生</MenuItem>
                            </SubMenu>
                            <MenuItem Key="2">
                                    <Icon Type="setting" Theme="outline" />
                                <NavLink href="/config">网站配置</NavLink>
                            </MenuItem>
                        }                           
                    }                                       
                </Menu>
                </Authorized>
                <NotAuthorized>
                    <Menu Theme="MenuTheme.Dark" DefaultSelectedKeys=@(new[]{"0"}) Mode="MenuMode.Inline">
                        <MenuItem Key="0">
                            <Icon Type="home" Theme="outline" />
                            <NavLink href="/">返回首页(尚未登录)</NavLink>
                        </MenuItem>
                    </Menu>
                </NotAuthorized>
            </AuthorizeView>        
        </Affix>
    </Sider>
    <Layout Class="site-layout">
        <Header Class="site-layout-background" Style=" padding: 0 ;">
            <div style="float:right;margin:0 16px;">
                <UserButton/>
            </div>           
        </Header>
        <Content Style="margin:0 16px;">
@*            <Breadcrumb Style="margin:16px 0;">
                <BreadcrumbItem>User</BreadcrumbItem>
                <BreadcrumbItem>Bill</BreadcrumbItem>
            </Breadcrumb>*@
            <div class="site-layout-background" style="padding: 24px; min-height: 360px">
                @Body
            </div>
        </Content>
        <Footer>
            <Divider>欢迎来到这个站点</Divider>
        </Footer>
    </Layout>
</Layout>


<style>
    #components-layout-demo-side .logo {
        height: 32px;
    /*   background: rgba(255, 255, 255, 0.2);*/
        margin: 16px;
    }

    .site-layout .site-layout-background {
        background: #fff;
    }
</style>
